<?php
class sort{
	public function init($params=array()){
		$this->db=$this->yum->library('mysql');
		$this->prefix=$this->yum->vars('app','prefix');
	}
	public function Count($params=array()){
		$params['select']='COUNT(*) AS count';
		return $this->db->select($this->prefix.'sort',$params);
	}
    public function GSort($params=array()){
    	return $this->db->select($this->prefix.'sort',$params);
    }
    public function SortTree($params=array(),$parent=0){
		$view=$this->GSort($params);
		return $this->GTree($view,$parent);
    }
	public function ISort($params){
		return $this->db->insert($this->prefix.'sort',$params);
	}
	public function USort($params){
		return $this->db->update($this->prefix.'sort',$params);
	}
	public function GTree($data,$parent=0){
		$tree=$this->yum->library('tree');
		$tree->set($data);
		return $tree->build($parent);
	}
}
?>